package com.forest.dto;

import lombok.Data;

/**
 *
 * @author Administrator
 */
@Data
public class ResultResponse<T> {

    private String code;

    private String message;

    private T  data;

    public static <T> ResultResponse<T> success(String code, String message,T data) {
        ResultResponse<T> resultResponse = new ResultResponse<>();
        resultResponse.setCode(code);
        resultResponse.setMessage(message);
        resultResponse.setData(data);
        return resultResponse;
    }

    public static <T> ResultResponse<T> success(String code, String message) {
        return success(code, message, null);
    }

    public static <T> ResultResponse<T> success(T data) {
        return success("200", "success", data);
    }

    public static <T> ResultResponse<T> success() {
        return success("200", "success", null);
    }

    public static <T> ResultResponse<T> fail(String code, String message) {
        return fail(code, message, null);
    }

    public static <T> ResultResponse<T> fail(String code, String message,T data) {
        ResultResponse<T> resultResponse = new ResultResponse<>();
        resultResponse.setCode(code);
        resultResponse.setMessage(message);
        resultResponse.setData(data);
        return resultResponse;
    }
}
